package cn.tedu.boot101.controller;

import cn.tedu.boot101.entity.Class;
import cn.tedu.boot101.mapper.ClassMapper;
import cn.tedu.boot101.mapper.StudentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/class/")
public class ClassController {
    @Autowired
    ClassMapper cm;

    @RequestMapping("select")
    public List<Class> select() {
        return cm.select();
    }

    @RequestMapping("selectById")
    public Class selectById(int id) {
        return cm.selectById(id);
    }

    @RequestMapping("insert")
    public void insert(@RequestBody Class c) {
        cm.insert(c);
    }

    @Autowired
    StudentMapper sm;

    @RequestMapping("delete")
    public void delete(int id) {
        cm.deleteById(id);
        sm.selectByCid(id);
    }

}
